// UserStatisticsMapper.java
package com.example.smartgreenhouse.mapper;

import com.example.smartgreenhouse.entity.UserStatistics;
import org.apache.ibatis.annotations.*;

public interface UserStatisticsMapper {
    @Insert("INSERT INTO user_statistics (user_id, today_visits, weekly_active_days, total_visits, last_access_date, last_week_number) " +
            "VALUES (#{userId}, #{todayVisits}, #{weeklyActiveDays}, #{totalVisits}, #{lastAccessDate}, #{lastWeekNumber})")
    void insert(UserStatistics userStatistics);

    @Update("UPDATE user_statistics SET " +
            "today_visits = #{todayVisits}, " +
            "weekly_active_days = #{weeklyActiveDays}, " +
            "total_visits = #{totalVisits}, " +
            "last_access_date = #{lastAccessDate}, " +
            "last_week_number = #{lastWeekNumber} " +
            "WHERE user_id = #{userId}")
    void update(UserStatistics userStatistics);

    @Select("SELECT * FROM user_statistics WHERE user_id = #{userId}")
    UserStatistics findByUserId(Long userId);
}